<template>
    <div class="row">
        <el-checkbox v-model="comp.enabled">{{ comp.__classname__ }}</el-checkbox>
        <el-button round size="small" :icon="Document" @click="gm.toConsole(comp)"></el-button>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>CustomMaterial</el-text>
        <el-input size="small" disabled :value="gm.targetName(comp.customMaterial)" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>LineWidth</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.lineWidth" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>LineJoin</el-text>
        <el-select v-model="comp.lineJoin" size="small">
            <el-option v-for="item in lineJoin.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>LineCap</el-text>
        <el-select v-model="comp.lineCap" size="small">
            <el-option v-for="item in lineCap.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>StrokeColor</el-text>
        <el-color-picker size="small" color-format="hex" show-alpha v-model="Model.strokeColor" />
        <el-input size="small" v-model="Model.strokeColor" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>FillColor</el-text>
        <el-color-picker size="small" color-format="hex" show-alpha v-model="Model.fillColor" />
        <el-input size="small" v-model="Model.fillColor" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>MiterLimit</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.miterLimit" />
    </div>
</template>

<script lang="ts" setup>
import { Document } from '@element-plus/icons-vue'
import gm from './gm'

const props = defineProps<{
    comp: CCComponent,
    update: Number,
}>()
const lineJoin = cc.Graphics.LineJoin
const lineCap = cc.Graphics.LineCap

class Model {
    static get comp() {
        return props.comp
    }

    static get strokeColor() {
        return gm.toHexColor(this.comp.strokeColor)
    }

    static set strokeColor(value: string) {
        this.comp.strokeColor = gm.toCCColor(value)
    }

    static get fillColor() {
        return gm.toHexColor(this.comp.fillColor)
    }

    static set fillColor(value: string) {
        this.comp.fillColor = gm.toCCColor(value)
    }
}
</script>